<?php $this->load->view('header'); ?>
<div id="content">
<div class="column full fl">
		
		<div class="box">
		<div class="box-header"><?php echo get_title();?></div>
		<div class="box-content box-table">
		<br />
		<?php echo isAccess('myuser','message','add') ? anchor('myuser/message/add/tipe/' . $uri_to_assoc['tipe'], '<span class="icon_text addnew"></span>Post Message', 'class="button white fr"') : ''; ?>
		
        <?php if ($uri_to_assoc['tipe'] == 'inbox') : ?>
        <?php echo isAccess('myuser','message','message') ? anchor('myuser/message/view/tipe/outbox', '<span class="icon_text pack _40"></span>View Outbox', 'class="button white fr" style="margin-left:10px;"') : ''; ?>
        <?php endif;?>
        <?php if ($uri_to_assoc['tipe'] == 'outbox') : ?>
        <?php echo isAccess('myuser','message','message') ? anchor('myuser/message/view/tipe/inbox', '<span class="icon_text pack _41"></span>View Inbox', 'class="button white fr" style="margin-left:10px;"') : ''; ?>
        <?php endif;?>
        &nbsp;
		<div class="clear"></div>

		<table class="tablebox">
		<thead class="table-header" style="border-top:1px solid #ccc;border-bottom:1px solid #ccc">
		<tr>
			  <th width="5%">No</td>
	          <th width="5%">Status</td>
	          <?php if($uri_to_assoc['tipe'] == 'inbox'):?>
	          	<th width="20%">Dari</td>
			  <?php else:?>
	          	<th width="20%">Kepada</td>
	          <?php endif?>
              <th width="40%">Judul Pesan</td>
              <th width="15%">Waktu</td>
              <th width="20%">Action</td>
		</tr>
		</thead>
		<tbody>
            <?php $i = true ;?>
            <?php $no = $uri_to_assoc['page'] + 1?>
			<?php if ($listMessage) : foreach($listMessage as $row) : ?>
                    <?php $i = $i ? false : true ; ?>
                    <tr class="<?php echo $i ? 'even' : 'odd' ; ?>">
                    	<td><?php echo $no?></td>
                        <td>
                            <?php if ($row['userMessageTipe'] == 'inbox') : ?>
                            	<?php $icon = $row['userMessageStatus'] ? '37' : '38';?>
                            	<?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'], '<span class="icons_pack"><span class="icon_ pack _'.$icon.'"></span></span>');?>
                            <?php else : ?>
                            	<?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'], '<span class="icons_pack"><span class="icon_ pack _39"></span></span>');?>
                            <?php endif;?>
                        </td>
                        <td>
                        	<?php if ($row['userMessageTipe'] == 'inbox') : ?>
                        		<?php $userNameFrom = $row['userMessageStatus'] ? '<b>'.$row['userNameFrom'].'</b>' : $row['userNameFrom'];?>
                            	<?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'], $userNameFrom);?>
                            <?php else : ?>
                            	<?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'], $row['userNameTo']);?>
                            <?php endif;?>
                        </td>
                        <td>
                            <?php if ($row['userMessageStatus']) : ?>
                            	<b><?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'],$row['userMessageTitle']);?></b>
                            <?php else : ?>
                            	<?php echo anchor('myuser/message/detail/tipe/'.$row['userMessageTipe'].'/id/' . $row['userMessageId'],$row['userMessageTitle']);?>
                            <?php endif;?>
                        </td>
                        <td>
                        	<?php //if( date('Y-m-d') != date('Y-m-d',SQLTimeToMKTime($row['userMessageCreateTime'])) ):?>
                            	<?php //echo date('d M Y',SQLTimeToMKTime($row['userMessageCreateTime']));?>
                            <?php //endif?>
                            
                            <?php echo date('d M Y',SQLTimeToMKTime($row['userMessageCreateTime']));?>,
                            <?php echo date('H:i',SQLTimeToMKTime($row['userMessageCreateTime']));?>
                        </td>
                        <td align="center">
                            <?php echo anchor('myuser/message/view/tipe/'.$row['userMessageTipe'].'/page/'.$uri_to_assoc['page'].'/action/delete/id/'. $row['userMessageId'] .'/time/' . time(), '<span class="icon_text cancel"></span>Hapus', 'class="button white fl" style="margin-left:10px;"') ?>
                            &nbsp;
                        </td>
                    </tr>
                    <?php $no++;?>
                    <?php endforeach; endif;?>
		</tbody>
		</table>
		<div id="paging">
                <?php echo $pages_html;?>
            </div>
		</div>
		</div>
	
	</div>

<?php $this->load->view('footer'); ?>